package acm.pta12;

import java.util.Scanner;

public class 不变初心数 {
    static final int[] nums={3,4,5,6,7,8,9};
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        while (n-- > 0) {
            int num = scanner.nextInt();
            int fixed = getNum(num,2);
            if (isFixed(num,fixed)){
                System.out.println(fixed);
            }else {
                System.out.println("NO");
            }
        }
    }
    public static boolean isFixed(int n,int fixed){
        for (int num : nums) {
            int fx2 = getNum(n, num);
            if (fx2 != fixed) return false;
        }
        return true;
    }
    public static int getNum(int n,int mulriple){
        n*=mulriple;
        int res=0;
        while (n != 0) {
            res+=n%10;
            n/=10;
        }
        return res;
    }
}
